package com.javasm.springmybatis.sync;

import com.javasm.springmybatis.utils.SpringContainerUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @Author：zzt
 * @Version：1.0
 * @Date：2021/11/9-22:33
 * @Since:jdk1.8
 * @Description:
 */
public class AsyncManager {
    private static ThreadPoolTaskExecutor executor;
    private static AsyncManager asyncManager;
    private AsyncManager(){
        executor = SpringContainerUtils.getBean(ThreadPoolTaskExecutor.class);
        System.out.println(executor.getCorePoolSize());
    }

    public static AsyncManager getInstance(){
        if (asyncManager==null){
            return new AsyncManager();
        }
        return asyncManager;
    }
    public void execute(Runnable runnable){
        executor.execute(runnable);
    }
}
